<!DOCTYPE html>
<!-- 问题编辑页 -->
<!-- @author DHC -->
<!-- 2020/04/25 -->
<html style="background: white;">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no viewport-fit=cover" />
		<script src="../../Common/js/tools.js"></script>
		<script src="../../Common/js/lib/jquery-3.4.1.min.js"></script>
		<script src="../../Common/js/lib/materialize.min.js"></script>
		<script src="../../Common/js/lib/summernote-0.8.16-dist/summernote-lite.min.js"></script>
		<script src="../../Common/js/lib/summernote-0.8.16-dist/lang/summernote-zh-CN.min.js"></script>
		<script src="../../Common/js/summernote-fix.js"></script>
		<link rel="stylesheet" href="../../Common/css/ufun.css" />
		<link rel="stylesheet" href="../../Common/css/lib/materialize.min.css">
		<link rel="stylesheet" href="../../Common/js/lib/summernote-0.8.16-dist/summernote-lite.min.css" />
		<link rel="stylesheet" href="../../Common/css/summernote-fix.css"/>
		<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
		<style>
			#LastLogCard {
				padding: 3vw 4vw;
				margin: 0 0 1vw 0;
			}
			
			#LastLogUserInfo {
				height: 11vw;
				width: 100%;
				display: block;
			}
			
			#LastLogUserHeadImg {
				width: 10vw;
				height: 10vw;
				border-radius: 50%;
				float: left;
				border: 1px solid #AAAAAA;
				margin-right: 2.2vw;
			}
			
			#LastLogUserNick {
				font-size: 4vw;
				line-height: 10.5vw;
			}
			
			#LastLogText {
				margin-top: 2vw;
				max-height: 50vh;
				overflow: auto;
			}
			</style>
	</head>
	<body>
		<header>
			<div id="Left" class="com-btn" onmouseup="ThisClose();">
				<i class="material-icons">keyboard_arrow_left</i>
			</div>
			<div id="Title">回复问题</div>
			<div id="Right" class="com-btn" onmouseup="submit();">发布</div>
		</header>
		<div class="content fixed">
			<form class="editor-form">
				<div id="LastLogCard">
					<div id="LastLogUserInfo">
						<img id="LastLogUserHeadImg" />
						<div id="LastLogUserNick"></div>
					</div>
					<div id="LastLogText" class="note-editor"></div>
				</div>
				<div class="note-relative">
					<textarea rows="30" type="text" placeholder="输入回复内容" id='Reply'></textarea>
				</div>
			</form>
		</div>
	</body>
	<script>
		var userHash;
		var current;
		var quesId;
		var lastLog;
		var lastLogContent = ID("LastLogCard");
		var lastLogUserHeadImg = ID("LastLogUserHeadImg");
		var lastLogUserNick = ID("LastLogUserNick");
		var lastLogText = ID("LastLogText");
		var content = $('#Reply');
		SummerNoteInit(content, '输入回复内容');

		document.addEventListener('plusready', function() {
			GetStatusTop();
			userHash = plus.storage.getItem('userHash');
			current = plus.webview.currentWebview();
			quesId = current.quesId;
			lastLog = current.lastLog;
			lastLogUserHeadImg.src = SERVER_LOC + lastLog["uHeadImgLoc"];
			lastLogUserNick.textContent = lastLog["uNick"];
			lastLogText.textContent = "" + lastLog["quesLogText"];
			current.show("slide-in-bottom", 300);
		});

		function submit() {
			let replyText = content.summernote('code');
			if (replyText.trim() == "") {
				plus.nativeUI.alert("提交内容为空，请检查", "提示");
				return;
			}
			CallAJAX("changeQuesLog", {
				"userHash": userHash,
				"quesId": quesId,
				"quesLogText": replyText,
				"action": "write"
			}, function(data) {
				switch (data["res"]) {
					case "1":
					case "2":
						plus.nativeUI.alert("请检查您回答的题目是否有效", "提交失败");
						break;
					case "ok":
						ThisClose();
					default:
				}
			});
		}
	</script>
</html>
